package cn.qicaiwang.open.system.mapper;

import cn.qicaiwang.open.system.model.entity.SystemUser;
import cn.qicaiwang.open.system.model.req.SystemUserREQ;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * SystemUserMapper继承基类
 */
public interface SystemUserMapper extends BaseMapper<SystemUser> {
    @Select("select * from system_user where phone = #{mobile}")
    SystemUser selectOneByMobile(String mobile);

    @Select("select * from system_user where username = #{username}")
    SystemUser selectOneByUserName(String username);

    @Select("select * from system_user where email = #{email}")
    SystemUser selectOneByEmail(String email);

    Page<SystemUser> page(Page page, @Param("params") SystemUserREQ params);

    @Update("update system_user set del_flag = 0 where id = #{id}")
    int restore(String id);

    @Delete("delete from system_user where del_flag = 1")
    int clear();
    @Select("select *  from system_user where del_flag = 1 ")
    Page<SystemUser> recyclebin(Page page);

    String selectWithAvatar(String username);
}